<!DOCTYPE html>
<!--   thymeleaf   -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="webtest/head::copyhead">  </head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <b>后台管理系统</b>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">请登录系统</p>

        <form action="account/login" method="post" id="loginForm">
            <div class="form-group has-feedback warning-div" id="usernameDiv">
                <label class="control-label warning-label" style="display:none;" for="username" id="usernameLabel">
                    <i class="fa fa-bell-o"></i>请输入用户名</label>
                <input type="text" class="form-control" name="username" id="username" placeholder="账号">
                <!-- <span class="glyphicon glyphicon-envelope form-control-feedback"></span> -->
            </div>
            <div class="form-group has-feedback warning-div" id="passwordDiv">
                <label class="control-label warning-label" style="display:none;" for="password" id="passwordLabel">
                    <i class="fa fa-bell-o"></i>请输入密码</label>
                <input type="password" class="form-control" name="password" id="password" placeholder="密码">
                <!-- <span class="glyphicon glyphicon-lock form-control-feedback"></span> -->
            </div>

            <div class="row">
                <div class="col-xs-8">
                    <div class="checkbox icheck">
                        <label>
                            <input type="checkbox" id="remember">记住我
                        </label>
                    </div>
                </div>
                <!-- /.col -->
                <div class="col-xs-4">
                    <center>
                        <button type="button" id="loginBtn" class="btn btn-primary btn-block btn-flat">登 录</button>
                    </center>
                </div>
            </div>
        </form>
    </div>
</div>

<!-- jQuery 3 -->
<script src="../../bower_components/jquery/dist/jquery.min.js" th:src="@{~/bower_components/jquery/dist/jquery.min.js}"
        }></script>
<!-- Bootstrap 3.3.7 -->
<script src="../../bower_components/bootstrap/dist/js/bootstrap.min.js"
        th:src="@{~/bower_components/bootstrap/dist/js/bootstrap.min.js}" }></script>
<!-- iCheck -->
<script src="../../plugins/iCheck/icheck.min.js" th:src="@{~/plugins/iCheck/icheck.min.js}" }></script>
<!--<script src="../js/util/jquery.serializejson.min.js"></script>-->
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' /* optional */
        });

        $("#loginBtn").click(function () {
            var username = $.trim($("#username").val());
            var password = $.trim($("#password").val());
            if (username == "") {
                alert("请输入用户名");
                return false;
            } else if (password == "") {
                alert("请输入密码");
                return false;
            }
            $.ajax({
                type: "post",
                url: "/login/admin.do",
                async: false,
                data: JSON.stringify(password),       /*前端数据转换为JSon数据格式*/
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.status == 0) {
                        window.location.href = "/index/planeInfo";   /*跳转页面，后台实现*/
                    }
                    if (data.status == -1)
                        alert(data.msg);//弹出错误信息
                },
                error: function (msg) {//ajax请求失败后触发的方法
                    alert("请求失败,请重试" + "")
                }
            });

        });
    });
</script>
</body>
</html>